//package boundaryToMatador;
//
////import java.awt.Color;
//import android.graphics.Point;
////import java.awt.event.ActionEvent;
////import java.awt.event.ActionListener;
////import java.awt.event.KeyEvent;
////import java.awt.event.KeyListener;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Random;
//import java.util.concurrent.CountDownLatch;
////import javax.swing.JButton;
////import javax.swing.JComboBox;
////import javax.swing.JTextField;
////import javax.swing.SwingConstants;
//
///**
// * Provides access to GUI
// * @author Ronnie
// */
//final class BoardController {
//	static String userInput = null;
//	Board board;
//	private static volatile Random rand = null;
//	
//	public static Random rand() {
//		if(rand == null) {
//		    synchronized (BoardController.class) {
//		        if(rand == null) rand = new Random();
//            }
//		}
//		return rand;
//	}
//	/**
//	 * Contains service methods for board for controlling the board.
//	 */
//	public BoardController() {
//		this.board = Board.getInstance();
//	}
//	/**
//	 * Displays a message for the user. The user presses OK when the message is read Is a breaking
//	 * call.<br>
//	 * @param msg The message for the user.
//	 */
//	public void showMessage(String msg) {
////		final CountDownLatch latch = new CountDownLatch(1);
////		JButton okButton = new JButton("OK");
////		okButton.addActionListener(new ActionListener() {
////			
////			@Override
////			public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
////				BoardController.this.board.clearInputPanel();
////				latch.countDown();
////			}
////		});
////		this.board.getUserInput(msg, okButton);
////		try {
////			latch.await();
////		} catch(InterruptedException ex) {
////			ex.printStackTrace();
////		}
//	}
//	/**
//	 * Displays a message for the user and a textfield for the user to fill out.<br>
//	 * Is a breaking call.<br>
//	 * @param msg The message for the user.
//	 * @return The text entered by the user.
//	 */
//	public String getUserString(String msg) {
////		final CountDownLatch latch = new CountDownLatch(1);
////		final JTextField tf = new JTextField(20);
////		JButton okButton = new JButton("OK");
////		okButton.addActionListener(new ActionListener() {
////			
////			@Override
////			public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
////				BoardController.userInput = tf.getText();
////				BoardController.this.board.clearInputPanel();
////				latch.countDown();
////			}
////		});
////		this.board.getUserInput(msg, tf, okButton);
////		
////		try {
////			latch.await();
////			return BoardController.userInput;
////		} catch(InterruptedException ex) {
////			ex.printStackTrace();
////			return null;
////		}
//		return msg;
//	}
//	/**
//	 * Closes the GUI, so you can start a new one.
//	 */
//	public void closeGUI() {
//		Board.destroy();
//	}
//	/**
//	 * Adds a player to the board.<br>
//	 * A new player with the same color will replace the old.<br>
//	 * Max. 6 players.<br>
//	 * @param name : String (Mind the length!)
//	 * @param balance : int<br>
//	 *        Automatic coloring
//	 */
//	public void addPlayer(String name, int balance) {
//		this.board.addPlayer(name, balance);
//	}
//	/**
//	 * Shows two dice on the board. The dice will have the specified values, but the placement is
//	 * random.<br>
//	 * @param faceValue1 : int [1:6]
//	 * @param faceValue2 : int [1:6]<br>
//	 *        (If a faceValue is out of bounds nothing will happen!)
//	 */
//	public void setDice(int faceValue1, int faceValue2) {
//		int rotation1 = rand().nextInt(360);
//		int rotation2 = rand().nextInt(360);
//		setDice(faceValue1, rotation1, faceValue2, rotation2);
//	}
//	/**
//	 * Shows two dice on the board. The dice will have the specified values and location.<br>
//	 * @param faceValue1 : int [1:6]
//	 * @param x1 : int [0:10]
//	 * @param y1 : int [0:10]
//	 * @param faceValue2 : int [1:6]
//	 * @param x2 : int [0:10]
//	 * @param y2 : int [0:10]
//	 */
//	public void setDice(int faceValue1, int x1, int y1, int faceValue2, int x2, int y2) {
//		int rotation1 = rand().nextInt(360);
//		int rotation2 = rand().nextInt(360);
//		setDice(faceValue1, rotation1, x1, y1, faceValue2, rotation2, x2, y2);
//	}
//	/**
//	 * Shows two dice on the board. The dice will have the specified values, but the placement is
//	 * random.<br>
//	 * @param faceValue1 : int [1:6]
//	 * @param rotation1 : int [0:2]
//	 * @param faceValue2 : int [1:6]
//	 * @param rotation2 : int [0:2]<br>
//	 *        (If a faceValue is out of bounds nothing will happen!)
//	 */
//	public void setDice(int faceValue1, int rotation1, int faceValue2, int rotation2) {
//		// Make an accepted locations for a dice
//		List<Point> dicePlaces = new ArrayList<Point>();
//		for(int x = 1; x < 10; x++) {
//			for(int y = 1; y < 10; y++) {
//				if(x >= 4 && x <= 6 && y >= 4 && y <= 6) {
//					continue;
//				} // Do not add the points in the center.
//				if(x > 6 && y > (9 - this.board.getPlayerCount())) {
//					continue;
//				} // Do not add the points used for the players names and balances.
//				dicePlaces.add(new Point(x, y));
//			}
//		}
//		
//		// Randomly choose a location for die1
//		int index1 = 0;
//		index1 = (int) (Math.random() * dicePlaces.size());
//		Point dice1Position = dicePlaces.remove(index1);
//		
//		// Remove all locations "far" away from die1
//		final int MAX_DISTANCE = 2;
//		ArrayList<Point> toBeRemoved = new ArrayList<Point>();
//		for(Point p : dicePlaces) {
//			if(p.x < dice1Position.x - MAX_DISTANCE || p.x > dice1Position.x + MAX_DISTANCE
//				|| p.y < dice1Position.y - MAX_DISTANCE || p.y > dice1Position.y + MAX_DISTANCE) {
//				toBeRemoved.add(p);
//			}
//		}
//		dicePlaces.removeAll(toBeRemoved);
//		
//		// Randomly choose a location for die2
//		int index2 = 0;
//		index2 = (int) (Math.random() * dicePlaces.size());
//		Point dice2Position = dicePlaces.get(index2);
//		
//		setDice(faceValue1, rotation1, dice1Position.x, dice1Position.y, faceValue2, rotation2,
//			dice2Position.x, dice2Position.y);
//	}
//	/**
//	 * Shows two dice on the board. The dice will have the specified values, location and rotation.<br>
//	 * @param faceValue1 : int [1:6]
//	 * @param rotation1 : int [0:2]
//	 * @param x1 : int [0:10]
//	 * @param y1 : int [0:10]
//	 * @param faceValue2 : int [1:6]
//	 * @param rotation2 : int [0:2]
//	 * @param x2 : int [0:10]
//	 * @param y2 : int [0:10]
//	 */
//	public void setDice(int faceValue1, int rotation1, int x1, int y1, int faceValue2,
//		int rotation2, int x2, int y2) {
//	    boolean faceValuesAreValid = areFaceValuesValid(faceValue1, faceValue2);
//	    boolean rotationsAreValid = areRotationsValid(rotation1, rotation2);
//	    boolean positionsAreValid = arePositionsValid(x1, y1, x2, y2);
//		if(faceValuesAreValid && rotationsAreValid && positionsAreValid) {
//			this.board.setDice(x1, y1, faceValue1, rotation1, x2, y2, faceValue2, rotation2);
//		}
//	}
//	private boolean arePositionsValid(int x1, int y1, int x2, int y2) {
//	    return x1 >= 0 && x1 <= 10
//            && y1 >= 0 && y1 <= 10
//            && x2 >= 0 && x2 <= 10
//            && y2 >= 0 && y2 <= 10;
//	}
//	private boolean areRotationsValid(int rotation1, int rotation2) {
//	    return rotation1 >= 0 && rotation1 <= 359
//            && rotation2 >= 0 && rotation2 <= 359;
//	}
//    private boolean areFaceValuesValid(int faceValue1, int faceValue2) {
//        return faceValue1 >= 1 && faceValue1 <= 6
//			&& faceValue2 >= 1 && faceValue2 <= 6;
//    }
//}